public enum Enum1 {
    //枚举类对象
    RED("red",1),
    BLACK("black",2),
    GREEN("green",3);
    private String color;
    private int ordiary;
    Enum1(String color,int ordiary ) {              //枚举的构造方法默认是私有的
        this.color = color;
        this.ordiary = ordiary;
    }
    public static void main(String[] args) {
        Enum1 enum1 = RED;
        switch (enum1) {
            case RED:
                System.out.println("red");
                break;
            case BLACK:
                System.out.println("black");
                break;
            case GREEN:
                System.out.println("green");
                break;
        }
        Enum1[] enum1s = Enum1.values();                                        //获取每个枚举对象
        for (int i = 0; i < enum1s.length; i++) {
            System.out.println(enum1s[i] + " 索引 : " + enum1s[i].ordinal());   //获取枚举对象的索引值
        }
        System.out.println(RED.compareTo(GREEN));                              //比较两个枚举成员在定义时的顺序
        System.out.println(Enum1.valueOf("GREEN"));                      //将普通字符串转换为枚举实例
    }
}
